﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:RealWorldStocks.UI.Controls" 
    mc:Ignorable="d">


    <Style TargetType="controls:PriceChangeArrow">
    	<Setter Property="Height" Value="16"></Setter>
		<Setter Property="Width" Value="16"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:PriceChangeArrow">

                    <Grid Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
                		<VisualStateManager.VisualStateGroups>
                			<VisualStateGroup x:Name="PriceStates">
                				<VisualStateGroup.Transitions>
                					<VisualTransition GeneratedDuration="0:0:0.5"/>
                				</VisualStateGroup.Transitions>
                				<VisualState x:Name="Negative">
                					<Storyboard>
                						<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="Arrow" d:IsOptimized="True"/>
                					</Storyboard>
                				</VisualState>
                				<VisualState x:Name="Positive">
                					<Storyboard>
                						<DoubleAnimation Duration="0" To="180" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="Arrow" d:IsOptimized="True"/>
                					</Storyboard>
                				</VisualState>
                			</VisualStateGroup>
                		</VisualStateManager.VisualStateGroups>   

                		<Path x:Name="Arrow" Stretch="Fill" Fill="{TemplateBinding Foreground}" Data="F1 M 7.00001,2L 13,2C 13.5523,2 14,2.44771 14,3L 13.9999,9L 16.9999,9C 17.5522,9 17.9999,9.44771 17.9999,10L 10.7072,17.2426C 10.3166,17.6332 9.68346,17.6332 9.29295,17.2426L 1.99992,10C 1.99992,9.44771 2.44764,9 2.99992,9L 5.99992,9L 6.00001,3C 6.00001,2.44771 6.44772,2 7.00001,2 Z " RenderTransformOrigin="0.5,0.5">
                			<Path.RenderTransform>
                				<CompositeTransform Rotation="90"/>
                			</Path.RenderTransform>
                		</Path>

                	</Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>



    <DataTemplate x:Key="NewsItemTemplate">
        <Grid HorizontalAlignment="Left" Width="250" Height="250">
            <Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}">

            </Border>
            <StackPanel VerticalAlignment="Bottom" Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}">
                <TextBlock Text="{Binding Title}" Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}" Style="{StaticResource TitleTextStyle}" Height="60" Margin="15,0,15,0"/>
                <TextBlock Text="{Binding ArticleDate}" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap" Margin="15,0,15,10"/>
            </StackPanel>
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="SnapshotItemTemplate">
        <Grid Width="250" Height="100" Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>

            <Grid VerticalAlignment="Top" Margin="10,10">


                <TextBlock Text="{Binding Symbol}" 
                               Style="{StaticResource TitleTextStyle}" />

                <TextBlock Text="{Binding Company}" 
                               Style="{StaticResource CaptionTextStyle}" 
                               HorizontalAlignment="Right"/>

            </Grid>

            <Grid Grid.Row="1">

                <StackPanel Orientation="Horizontal">
                    <controls:PriceChangeArrow Price="{Binding DaysChange}"  
                                               Width="30" 
                                               Height="30" 
                                               Foreground="{Binding DaysChange, Converter={StaticResource PriceChangeColorConverter}}" 
                                               VerticalAlignment="Bottom" 
                                               Margin="10,0,10,10"/>

                    <TextBlock Text="{Binding LastPrice}" 
                                   Style="{StaticResource TitleTextStyle}" 
                                   Margin="0,0,0,10"
                                   VerticalAlignment="Bottom" 
                                   Foreground="{Binding DaysChange, Converter={StaticResource PriceChangeColorConverter}}" 
                                   FontSize="26.667" />
                </StackPanel>

                <StackPanel HorizontalAlignment="Right" 
                                VerticalAlignment="Bottom"
                                Margin="0,0,10,10"
                                Orientation="Vertical">

                    <TextBlock Text="{Binding DaysChangeFormatted}" 
                                   Style="{StaticResource CaptionTextStyle}" 
                                   FontSize="14"
                                   FontWeight="Bold"
                                   Margin="0,0,0,1"
                                   Foreground="{Binding DaysChange, Converter={StaticResource PriceChangeColorConverter}}"  />

                    <TextBlock Text="{Binding DaysChangePercentFormatted}" 
                                   Style="{StaticResource CaptionTextStyle}" 
                                   FontSize="14"
                                   Foreground="{Binding DaysChange, Converter={StaticResource PriceChangeColorConverter}}"  />
                </StackPanel>

            </Grid>

        </Grid>
    </DataTemplate>


</ResourceDictionary>